package com.hxm.appGenealogy.Function;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hxm.appGenealogy.config.queryVo.QueryWrapperVO;
import com.hxm.appGenealogy.entity.People;
import com.hxm.appGenealogy.entity.PeopleService;
import com.hxm.appGenealogy.mapper.PeopleMapper;
import org.apache.ibatis.annotations.Update;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class PeopleFunction {

    @Autowired
    private PeopleMapper peopleMapper;

    /**
     * 根据id查询人的信息;
     *
     * @param id
     * @return
     */
    public People peopleGetByid(Long id) {
        People people = peopleMapper.selectById(id);
        return people;
    }

    public People updateByid(People people) {
        peopleMapper.updateById(people);
        return people;
    }

    public void delPeopleByid(Long id) {
        peopleMapper.deleteById(id);
    }

    public People insertPeople(People people){
        peopleMapper.insert(people);
        return people;
    }
    //条件查询，查询单个;
    public People queryGetOneString(String queryString){
        QueryWrapper<People> queryWrapper1 = QueryWrapperVO.getQueryWrapper(queryString);
        People people = peopleMapper.selectOne(queryWrapper1);
        return people;
    }
    //条件查询查询多个;
    public List <People> queryGeListString(String queryString){
        QueryWrapper<People> queryWrapper = QueryWrapperVO.getQueryWrapper(queryString);
        List <People>selectList = peopleMapper.selectList(queryWrapper);
        return selectList;
    }


}
